package com.ebs.md.fxmonitor.marketmonitor.alert;

/**
 * Perforce Revision:
 *  $File: //depot/MarketData/fxmonitor/main/src/main/java/com/ebs/md/fxmonitor/marketmonitor/alert/PulsingMessageCreator.java $
 *  $Revision: #2 $  $Change: 115140 $  $DateTime: 2012/09/24 08:51:26 $  $Author: Aviad.Yosef $
 */

import java.util.List;

import com.ebs.market.monitor.MarketMonitor.EventType;
import com.ebs.market.monitor.MarketMonitor.MarketIdentfier;
import com.ebs.market.monitor.MarketMonitor.OrderDetail;
import com.ebs.market.monitor.MarketMonitor.OutOfRegionQuotingEvent;
import com.ebs.market.monitor.MarketMonitor.PulsingEvent;
import com.ebs.md.fxmonitor.marketmonitor.model.PulseSingleFact;


public class PulsingMessageCreator
extends AbstractAlertMessageCreatorBySingleFact<PulsingEvent, PulseSingleFact>
{

	public PulsingMessageCreator(List<PulseSingleFact> dataList) {
		super(dataList);
	}

	@Override
	public PulsingEvent createAlertObject() {
		PulsingEvent.Builder builder = PulsingEvent.newBuilder();

		final PulseSingleFact firstDataElement = getFirstDataElement();
		{
		MarketIdentfier mi = gpbBuildMarketIdentifier(firstDataElement.getPair());
		builder.setMarketId(mi);
		}
		final String eventId = createEventIdByQuoteId(firstDataElement, firstDataElement.getTimestamp());
		builder.setEventId(eventId);
		builder.setEventTime(eventTimeMillis);
		builder.setConfigInstanceName(firstDataElement.getConfigInstanceName());
		{
		OrderDetail od = gpbBuildOrderDetail(firstDataElement);
		builder.setFirstQuote(od);
		}
		
		// set causing Quote IDs
		for ( PulseSingleFact curr : dataList ) {
			builder.addQuoteIds(curr.getQuoteId());
		}
		
		return builder.build();
	}

	@Override	
	public EventType getEventType() {
		return EventType.PULSING;
	}

}
